package com.ruoyi.iot.domain.dto;

import com.ruoyi.iot.domain.entity.DeviceElectricalWindow;
import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
import org.springframework.beans.BeanUtils;

/**
 * 设备电气窗口导出DTO
 */
@Data
public class DeviceElectricalWindowExportDTO {

/*    @Schema(description = "设备编号")
    private String deviceId;*/

    @Schema(description = "设备名称")
    private String deviceName;

    @Schema(description = "窗口开始时间")
    private LocalDateTime windowStart;

    @Schema(description = "窗口结束时间")
    private LocalDateTime windowEnd;

    @Schema(description = "聚合粒度(分钟)")
    private Integer granularityMinutes;

    @Schema(description = "样本数量")
    private Integer sampleCount;

    @Schema(description = "A相电流平均值")
    private BigDecimal avgIa;

    @Schema(description = "B相电流平均值")
    private BigDecimal avgIb;

    @Schema(description = "C相电流平均值")
    private BigDecimal avgIc;

/*    @Schema(description = "A相电流最大值")
    private BigDecimal maxIa;

    @Schema(description = "B相电流最大值")
    private BigDecimal maxIb;

    @Schema(description = "C相电流最大值")
    private BigDecimal maxIc;*/

    @Schema(description = "Uab电压平均值")
    private BigDecimal avgUab;

    @Schema(description = "Ubc电压平均值")
    private BigDecimal avgUbc;

    @Schema(description = "Uca电压平均值")
    private BigDecimal avgUca;

    @Schema(description = "功率因数平均值")
    private BigDecimal avgPowerfactor;

    @Schema(description = "有功能量(kWh)")
    private BigDecimal energyKwh;

    @Schema(description = "无功能量(kVarh)")
    private BigDecimal reactiveEnergy;

    @Schema(description = "有效数据占比")
    private BigDecimal qualityRate;

    /**
     * 将实体对象转换为导出DTO
     *
     * @param source 设备电气窗口实体
     * @param deviceName 设备名称
     * @return 导出DTO实例
     */
    public static DeviceElectricalWindowExportDTO from(DeviceElectricalWindow source, String deviceName) {
        DeviceElectricalWindowExportDTO target = new DeviceElectricalWindowExportDTO();
        BeanUtils.copyProperties(source, target);
        target.setDeviceName(deviceName);
        return target;
    }
}
